/*
 * Copyright 2006 Marc Wick, geonames.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package ca.cbc.gisdigester.geoparser;

import java.util.Collection;

import com.sun.syndication.feed.module.ModuleImpl;

/**
 * SimpleModuleImpl is the implementation of the {@link GeoRSSModule} Interface
 * for the GeoRSS Simple format.
 * 
 * @author Marc Wick
 * @version $Id: SimpleModuleImpl.java,v 1.3 2007/02/07 08:00:21 marcwick Exp $
 * 
 */
public class SimpleModuleImpl extends ModuleImpl implements GeoRSSModule {

	private GeoRSSPoint point;

	private Collection polygon;

	private Collection line;

	public SimpleModuleImpl() {
		super(GeoRSSModule.class, GeoRSSModule.GEORSS_GEORSS_URI);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.georss.rome.GeoRSSModule#setLatitude(double)
	 */
	public void setLatitude(double latitude) {
		if (point == null) {
			point = new GeoRSSPoint();
		}
		point.setLatitude(latitude);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.georss.rome.GeoRSSModule#setLongitude(double)
	 */
	public void setLongitude(double longitude) {
		if (point == null) {
			point = new GeoRSSPoint();
		}
		point.setLongitude(longitude);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.georss.rome.GeoRSSModule#getLatitude()
	 */
	public double getLatitude() {
		if (point != null) {
			return point.getLatitude();
		}
		return 0;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.georss.rome.GeoRSSModule#getLongitude()
	 */
	public double getLongitude() {
		if (point != null) {
			return point.getLongitude();
		}
		return 0;

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.sun.syndication.feed.CopyFrom#getInterface()
	 */
	public Class getInterface() {
		return GeoRSSModule.class;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.sun.syndication.feed.CopyFrom#copyFrom(java.lang.Object)
	 */
	public void copyFrom(Object obj) {
		SimpleModuleImpl geoRSSModule = (SimpleModuleImpl) obj;
		setPolygon(geoRSSModule.getPolygon());
		setLine(geoRSSModule.getLine());
		setPoint(geoRSSModule.getPoint());
	}

	/**
	 * @return the line
	 */
	public Collection getLine() {
		return line;
	}

	/**
	 * @param line
	 *            the line to set
	 */
	public void setLine(Collection line) {
		this.line = line;
	}

	/**
	 * @return the polygon
	 */
	public Collection getPolygon() {
		return polygon;
	}

	/**
	 * @param polygon
	 *            the polygon to set
	 */
	public void setPolygon(Collection polygon) {
		this.polygon = polygon;
	}

	/**
	 * @return the geoRSSPoint
	 */
	public GeoRSSPoint getPoint() {
		return point;
	}

	/**
	 * @param geoRSSPoint
	 *            the geoRSSPoint to set
	 */
	public void setPoint(GeoRSSPoint geoRSSPoint) {
		this.point = geoRSSPoint;
	}

}
